There is no need to use the final
specifier inside a final
class. Everything in it is final
by default.
Similarly, there is no need to use the final
specifier for union
, because union
s can neither extend other
classes nor be extended.
Noncompliant code example
class Base {
virtual void fun();
};
class Derived final : Base {
void fun() final; // Noncompliant
};
union MyUnion final { // Noncompliant
// ...
};
Compliant solution
class Base {
virtual void fun();
};
class Derived final : Base {
void fun() override;
};
union MyUnion {
// ...
};